namespace Microsoft.Sdc.Tasks.VersionNumber
{
    using System;
    using System.CodeDom;
    using System.CodeDom.Compiler;

    internal class CppCodeGenerator : ICodeGenerator
    {
        internal CppCodeGenerator()
        {
        }

        public bool Supports(GeneratorSupport supports)
        {
            return false;
        }

        public void GenerateCodeFromType(System.CodeDom.CodeTypeDeclaration e, System.IO.TextWriter w, CodeGeneratorOptions o)
        {
        }

        public string CreateValidIdentifier(string value)
        {
            return null;
        }

        public void GenerateCodeFromNamespace(System.CodeDom.CodeNamespace e, System.IO.TextWriter w, CodeGeneratorOptions o)
        {
        }

        public void GenerateCodeFromCompileUnit(System.CodeDom.CodeCompileUnit e, System.IO.TextWriter w, CodeGeneratorOptions o)
        {
            foreach (CodeAttributeDeclaration att in e.AssemblyCustomAttributes)
            {
                if (att.Name == "System.Reflection.AssemblyFileVersion")
                {
                    string val = string.Empty;
                    CodeExpression c = att.Arguments[0].Value;
                    if (c is CodePrimitiveExpression)
                    {
                        CodePrimitiveExpression cp = (CodePrimitiveExpression)c;
                        val = cp.Value.ToString().Replace(".", ",");

                        w.WriteLine("// This is a generated file. Do not modify or you may lose your changes");
                        w.WriteLine("#define _VERSION_NUMBER \t\t" + val);
                        w.WriteLine("#define _VERSION_NUMBER_STRING \t\t\"" + val + @"\0""");
                    }
                }
            }
        }

        public void GenerateCodeFromExpression(System.CodeDom.CodeExpression e, System.IO.TextWriter w, CodeGeneratorOptions o)
        {
        }

        public void GenerateCodeFromStatement(System.CodeDom.CodeStatement e, System.IO.TextWriter w, CodeGeneratorOptions o)
        {
        }

        public void ValidateIdentifier(string value)
        {
        }

        public string GetTypeOutput(System.CodeDom.CodeTypeReference type)
        {
            return null;
        }

        public string CreateEscapedIdentifier(string value)
        {
            return null;
        }

        public bool IsValidIdentifier(string value)
        {
            return false;
        }
    }
}
